define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'union/hostsharereward/index',
                    table: 'stat_daily_invite_reward',
                },
                commonSearch: true,
                searchFormVisible: true,
                visible: false,
                showToggle: false,
                showColumns: false,
                search:false,
                showExport: true,
            });

            var table = $("#table");
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 's.id',
                columns: [
                    [
                        {
                            field: 'dt',
                            title: __('日期'),
                            formatter: Table.api.formatter.datetime, datetimeFormat:"YYYY-MM-DD",
                            operate: 'RANGE',
                            addclass: 'datetimerange',
                        },
                        {field: 'user_profile_id', title: __('用户ID')},
                        {field: 'nick_name', title: __('用户昵称')},
                        {field: 'reward_coin', title: __('邀请充值（金币）'), operate: false},
                        {field: 'reward_coin_rmb', title: __('邀请充值（元）'), operate: false},
                    ]
                ]
            });
            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});